const duration = 2000
let timer
module.exports = {
  success: (title) => {
    wx.showToast({
      title: title,
      icon: 'success',
      duration: duration
    })
  },
  showLoading: (title = '', mask = true) => {
    timer = setTimeout(() => {
      clearTimeout(timer)
      timer = null
      wx.showLoading({
        title: title,
        mask: mask,
      }, 0.25)
    })
  },
  hideLoading: () => {
    if(timer) {
      clearTimeout(timer)
      timer = null
    }
    wx.hideLoading()
  },
  
  message: (title) => {
    wx.showToast({
      title: title,
      icon: 'none',
      duration: duration
    })
  }
}